package api

import (
	"github.com/gin-gonic/gin"
	"shop/api/handler"
	"shop/consts"
	"shop/pkg"
)

func Router(c *gin.Engine) {
	api := c.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/registerUser", handler.RegisterUser)

			user.POST("/loginUser", handler.LoginUser)

		}
		shop := api.Group("/shop")
		{
			shop.POST("/add", handler.AddShop)
			shop.POST("/queryIdShop", handler.QueryIdShop)

			shop.POST("/updateShop", handler.UpdateShop)
			shop.POST("/deleteShop", handler.DeleteShop)

		}

		context := api.Group("/context")
		{
			context.Use(pkg.JWTAuth(consts.JWT_SECRETKEY))
			context.POST("/add", handler.AddContext)
			context.POST("/queryIdShop", handler.QueryAllContext)

			context.POST("/updateContext", handler.UpdateContext)
			//context.POST("/deleteShop", handler.DeleteContext)

		}
		order := api.Group("/order")
		{
			order.Use(pkg.JWTAuth(consts.JWT_SECRETKEY))
			order.POST("/add", handler.AddOrder)
			order.POST("/queryOrder", handler.QueryOrder)

			order.POST("/updateOrder", handler.UpdateOrder)
			context.POST("/deleteOrder", handler.DeleteOrder)

		}

		api.POST("/test", handler.Test)

	}
}
